<template>
  <div class="searchInputBox">
    <a-input :placeholder="placeholder" class="searchInput" v-model:value="inputValue" @pressEnter="search">
      <template #prefix>
        <img src="@/assets/svg/common/searchImg.svg" alt="查询" />
      </template>
    </a-input>
    <span class="searchBtn" @click="search">查询</span>
  </div>
</template>

<script>
import { reactive } from 'vue'
export default {
  props: {
    placeholder: {
      type: String,
      default: ''
    },
    inputValue: {
      type: String,
      default: ''
    }
  },
  setup(props, context) {
    const moduleData = reactive({})

    const search = () => {
      context.emit('search', props.inputValue)
    }

    return {
      moduleData,
      search
    }
  }
}
</script>

<style lang="less">
.searchInputBox {
  display: inline-block;
  &:after {
    display: block;
    height: 0px;
    clear: both;
    content: '';
    visibility: hidden;
  }
  .searchInput {
    float: left;
    width: calc(100% - 52px);
    border-radius: 4px 0px 0px 4px;
    height: 34px;
  }
  .searchBtn {
    float: left;
    width: 52px;
    border: 1px solid #d9d9d9;
    border-left: none;
    border-radius: 0px 4px 4px 0px;
    height: 34px;
    line-height: 32px;
    text-align: center;
    font-size: 14px;
    color: #5975fb;
    user-select: none;
    cursor: pointer;
    &:hover {
      opacity: 0.7;
    }
    &:active {
      opacity: 0.95;
    }
  }
}
</style>
